/*******************************************************************************
 * Copyright (c) 2006 CEA List.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     CEA List - initial API and implementation
 *******************************************************************************/
package com.cea.papyrus.tabbedproperties.section;

import org.eclipse.jface.viewers.ISelection;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
import org.eclipse.uml2.uml.ObjectNode;

import com.cea.papyrus.core.tabbedproperties.PropertyViewSection;
import com.cea.papyrus.tabbedproperties.composites.IsControlTypeComposite;

/**
 * Section for isControl field of Pins
 *
 * @author Gilles Cannenterre
 * @since 11 avr. 07
 */
public class ObjectNodeIsControlTypeSection extends PropertyViewSection {
	
	/** The control composite. */
	private IsControlTypeComposite controlComposite;
	
	/* (non-Javadoc)
	 * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#createControls(org.eclipse.swt.widgets.Composite, org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage)
	 */
	@Override
	public void createControls(Composite parent,
            TabbedPropertySheetPage tabbedPropertySheetPage) {
		
        super.createControls(parent, tabbedPropertySheetPage);
        controlComposite = new IsControlTypeComposite();
        controlComposite.createContent(parent, tabbedPropertySheetPage.getWidgetFactory());
        
 	}

	/* (non-Javadoc)
	 * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#refresh()
	 */
	@Override
	public void refresh() {
		controlComposite.refresh();
	}
	
    /* (non-Javadoc)
     * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#setInput(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
     */
    @Override
	public void setInput(IWorkbenchPart part, ISelection selection) {
        super.setInput(part, selection);
        if (umlElement instanceof ObjectNode) {
			controlComposite.setElement((ObjectNode)umlElement);
		}
    }
    
    /*
     * (non-Javadoc)
     * @see com.cea.papyrus.core.ui.properties.tabbed.PropertyViewSection#dispose()
     */
    @Override
    public void dispose(){
    	super.dispose();
    	if(controlComposite!=null)
    		controlComposite.dispose();
    }
}